<template>
    <div class="trends-detail f f-ac f-col">
        <Breadcrumb router />
        <div class="trends-detail-body">
            <Title :label="detail.title" :time="detail.createtime" />
            <div class="body-bottom mt-30">
                <div v-if="detail.image && !detail.video" class="body-image f f-ac f-jc">
                    <img :src="baseUrl + detail.image" />
                </div>
                <video class="mt-30" :src="baseUrl+detail.video" :poster="baseUrl+detail.image" controls v-if="detail.video"/>
                <div class="body-content mt-20" v-html="detail.content" />
                <Action-bar :comment="detail.count" :like="detail.like" :collect="detail.collect" :type="7"
                    :is_like="detail.is_like" :is_collect="detail.is_collect" :id="detail.id" @like="handleLike" />
                <Comment :id="detail.id" @comfirm="handleComment" :type="7"/>
            </div>
        </div>
    </div>
</template>

<script>
    import {
        heritageDetail
    } from "@/utils/heritage/index.js";
    export default {
        data() {
            return {
                baseUrl: process.env.VUE_APP_BASE_API,
                detail: {},
            };
        },

        mounted() {},
        created() {
            this.detail.id = this.$route.query.id
            this.getDetails(this.detail.id);
        },
        methods: {
            // 获取详情
            getDetails(id) {
                this.loading = true;
                let that = this
                heritageDetail({
                    id
                }).then((response) => {
                    that.detail = response.data
                    that.loading = false;
                });
            },
            // 评论
            handleComment(v) {
                this.detail.comment = v;
            },
            // 点赞/收藏
            handleLike(v) {
                this.getDetails(v)
            }
        },
    };
</script>

<style lang="scss" scoped>
    .trends-detail {
        width: 100%;

        &-body {
            width: 1200px;
            padding-top: 20px;

            .body-bottom {
                video {
                    width: 100%;
                    height: 536px;
                    object-fit: cover;
                }

                .body-image {
                    width: 100%;

                    img {
                        width: 100%;
                        height: 618px;
                        object-fit: cover;
                    }
                }

                .body-content {
                    word-break: break-all;
                    padding-bottom: 30px;
                    border-bottom: 1px dashed #d9d9d9;
                }
            }
        }
    }
</style>